package com.aitesting.config;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;


//添加MyBatis-Plus的java配置，使用@MapperScan注解配置好需要扫描的Mapper接口路径
//MyBatis-Plus自带的分页功能，需要配置好分页插件paginationInterceptor
@SpringBootConfiguration
@MapperScan("com.aitesting.mapper")
public class MybatisConfig {
    @Bean
    public PaginationInterceptor paginationInterceptor(){
        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
        paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true));
        return paginationInterceptor;
    }
}
